$(function() {
	var dictArr = [{
			'id': 1,
			'email': '@EMAIL'
		},
		{
			'id': 2,
			'email': '@EMAIL'
		},
		{
			'id': 3,
			'email': '@EMAIL'
		}
	]

	//查询
	Mock.mock(/findDict/, {
		'list': dictArr
	})
	
	//删除
	Mock.mock(/deleteDict/, 'delete', function(options) {
		var arrId = options.body.split('='); //获取id
		dictArr.splice((arrId[1] - 1), 1)
		return dictArr
	})
	
	//添加
	Mock.mock(/addDict/, 'post', function(options) {
		var json = {};
		var arr = options.body.split('&');
		$.each(arr, function(index, value) {
			var tmp = value.split('=');
			json[tmp[0]] = tmp[1];
		});
		json.id = dictArr.length + 1 //json就是介绍的对象
		dictArr.push(json)
		return dictArr;
	})
	
	
	//随机数据
	Mock.mock(/hello.json/, {
		'list|1-10': [{
			'id|+1': 1,
			'email': '@EMAIL'
		}]
	})
})